package fudan.se.project.service.infrastructure.entity.conference.role;


import fudan.se.project.domain.User;
import fudan.se.project.domain.conference.post.Post;
import fudan.se.project.domain.conference.role.PcMember;
import fudan.se.project.repository.entity.conference.role.PcMemberRepository;
import fudan.se.project.service.infrastructure.base.IEntityService;
import org.springframework.stereotype.Service;

import java.util.Collection;

@Service
public class PcMemberService implements IEntityService<PcMember> {

    private final PcMemberRepository pcMemberRepository;

    public PcMemberService(PcMemberRepository pcMemberRepository) {
        this.pcMemberRepository = pcMemberRepository;
    }

    public PcMember findByUserAndPost(User user, Post post) {
        return pcMemberRepository.findByUserAndPost(user, post);
    }

    @Override
    public PcMember findById(long id) {
        return pcMemberRepository.findById(id);
    }

    @Override
    public PcMember save(PcMember pcMember) {
        return this.pcMemberRepository.save(pcMember);
    }

    @Override
    public Iterable<PcMember> saveAll(Collection<PcMember> pcMembers) {
        return this.pcMemberRepository.saveAll(pcMembers);
    }
}
